package com.jzo2o.foundations.controller.operation;

import com.jzo2o.common.model.PageResult;
import com.jzo2o.foundations.properties.model.dto.request.ServePageQueryReqDTO;
import com.jzo2o.foundations.properties.model.dto.request.ServeUpsertReqDTO;
import com.jzo2o.foundations.properties.model.dto.response.ServeResDTO;
import com.jzo2o.foundations.service.Iservice;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

/**
 * @author 11394
 * @version 1.0
 * @description: TODO
 * @date 2024/8/16 16:04
 */
@RestController("operationServeController")
@RequestMapping("/operation/serve")
@Api(tags = "运营端 - 服务相关接口")
public class ServerController {

    @Resource
    Iservice iservice;
    /**
    * @description
    * @author Gaosir
    * @return * @return: null
    * 服务列表页面
    * @date 2024/8/16 16:09
    */
    @GetMapping("/page")
    public PageResult<ServeResDTO> pageResult(ServePageQueryReqDTO servePageQueryReqDTO){

        return iservice.pageResult(servePageQueryReqDTO);
    }

    /**
    * @description
    * @author Gaosir
    * @return * @return: null
    * 服务添加
    * @date 2024/8/16 16:46
    */
   @PostMapping("/batch")
    public void addAll(@RequestBody List<ServeUpsertReqDTO> list){

       iservice.addAll(list);
   }

   /**
   * @description
   * @author Gaosir
   * @return * @return: null
   * 设置区域价格
   * @date 2024/8/16 17:16
   */
  @PutMapping("/{id}")
  public void regionPriceUpdate(@PathVariable(name = "id") Long id, @RequestParam(name = "price")BigDecimal price){

      iservice.regionPriceUpdate(id,price);
  }
  /**
  * @description
  * @author Gaosir
  * @return * @return: null
  * 区域服务上架
  * @date 2024/8/16 19:29
  */
  @PutMapping("onSale/{id}")
   public void  onSale(@PathVariable(name = "id")Long id){
      iservice.onSale(id);
  }

  /**
  * @description
  * @author Gaosir
  * @return * @return: null
  * 区域服务下架
  * @date 2024/8/16 20:39
  */
  @PutMapping("offSale/{id}")
   public void offSale(@PathVariable(name = "id")Long id){
      iservice.offSale(id);
  }
  /**
  * @description
  * @author Gaosir
  * @return * @return: null
  * 区域服务删除
  * @date 2024/8/16 20:51
  */
  @DeleteMapping("/{id}")
    public void dletedByid(@PathVariable(name = "id")Long id){

      iservice.dletedByid(id);
  }
  /**
  * @description
  * @author Gaosir
  * @return * @return: null
  * 区域服务设置热门
  * @date 2024/8/16 21:03
  */
  @PutMapping("/onHot/{id}")
  public void onHot(@PathVariable(name = "id")long id){

      iservice.onHot(id);
  }
  /**
  * @description
  * @author Gaosir
  * @return * @return: null
  * 区域服务取消热门
  * @date 2024/8/16 21:08
  */
  @PutMapping("/offHot/{id}")
  public void offHot(@PathVariable(name = "id")long id){
      iservice.offHot(id);
  }


            
}
